// 1. 封装查询文章列表API

import request from 'utils/request';

export const getArticleListAPI = (params) => {
  return request({
    url: '/v1_0/mp/articles',
    params,
  });
};

export const delArticleByIdAPI = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'DELETE',
  });
};

export const publishArticleAPI = (data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'POST',
    data,
  });
};

export const getArticleByIdAPI = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
  });
};

export const updateArticleAPI = (id, data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles/${id}?draft=${draft}`,
    method: 'PUT',
    data,
  });
};
